package com.md.api.google;

import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * google登录授权配置
 */
@Configuration
@Slf4j
public class GoogleAuthorizationConfig {
    private static final String clientId = "958735031113-pos61i3j0qdmlandhtpt2tvufngpe5nv.apps.googleusercontent.com";
    private static final  String clientSecret = "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";
    private static final  String applicationName = "picture-manage";
//    private static final  String redirectUrl = "https://www.baidu.com/";
    private static final  String redirectUrl = "https://kelzproductionhouse.com";


    @Bean(name = "googleAuthorization")
    public GoogleAuthorization googleFeed() {
        GoogleClientSecrets clientSecrets = null;
        try {
            GoogleClientSecrets.Details details = new GoogleClientSecrets.Details();
            details.setClientId(clientId);
            details.setClientSecret(clientSecret);
            clientSecrets = new GoogleClientSecrets();
            clientSecrets.setInstalled(details);
        } catch (Exception e) {
            log.error("authorization configuration error:{}", e.getMessage());
        }
        // 构建bean
        return GoogleAuthorization.builder()
                .googleClientSecrets(clientSecrets)
                .applicationName(applicationName)
                .redirectUrl(redirectUrl)
                .build();
    }
}
